package com.bishi;

import java.util.ArrayList;

public class 微盟33 {
    ArrayList<String> list = new ArrayList<>();
    public ArrayList<String> getPermutation(String A) {

        if(A != null && A.length()>0){
            dfs(A.toCharArray(),0);
        }
        return list;
    }

    public void dfs(char[] arr,int i){
        if(i == arr.length-1){
            String val = String.valueOf(arr);
            if(!list.contains(val)) {
                list.add(val);
            }
        } else {
            for(int j = 1; j < arr.length;j++){
                swap(arr, i, j);
                dfs(arr,i+1);
                swap(arr,i,j);
            }
        }

    }

    private void swap(char[] arr, int i, int j){
        char temp = arr[i];
        arr[i] = arr[j];
        arr[j] = arr[i];
    }
}
